function e(e, t, a) {
    return t in e ? Object.defineProperty(e, t, {
        value: a,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : e[t] = a, e;
}

var t, a = getApp(), i = require("../../utils/icon.js"), n = require("../../utils/point.js"), s = require("../../utils/scrollx.js");

require("../../utils/md5.min.js");

Page({
    data: (t = {
        title: "",
        house: {},
        building: {},
        imgUrls: [ "http://fang-oss.haozu.com/cms/index/2018/04/17/sRS6YK6pM7.jpg@750w_490h_1e_1c" ],
        tjlist: [],
        houseNum: 0,
        mapUrl: "",
        tel_phone: "",
        total: 0,
        currIndex: 1,
        share: 0,
        showYK: !1,
        shade: !1,
        subsucc: !1,
        hasError: !1,
        resPhone: "",
        isYK: !1,
        isDis: !1,
        isSC: !1,
        seeWidth: 0,
        ulen: 300,
        moveCurr: 0,
        shareimg: i.fenxiang,
        xingimg: i.xing,
        mapimg: i.mapimg,
        zhankai: i.zhankai,
        rightmore: i.rightmore,
        heart: i.heart,
        heart_red: i.heart_red,
        error_icon: i.error,
        close: i.close,
        gwheight: "",
        isUp: !0,
        consultant: []
    }, e(t, "consultant", ""), e(t, "consultantA", ""), e(t, "consultantA", []), t),
    changeCur: function(e) {
        this.setData({
            currIndex: e.detail.current + 1
        });
    },
    onShareAppMessage: function(e) {
        var t = this;
        return {
            title: t.data.title,
            desc: t.data.title,
            path: "/pages/house/house?share=1&house_id=" + t.data.house.id
        };
    },
    toMapInfo: function() {
        var e = this.data.house, t = this.data.building;
        wx.navigateTo({
            url: "/pages/map/map?name=" + e.building_name + "&address=" + t.address + "&lat=" + t.lat + "&lng=" + t.lng
        });
    },
    onLoad: function(e) {
        if (e.scene) {
            var t = decodeURIComponent(e.scene).split("&"), i = {
                type: t[0],
                id: t[1],
                phone: t[2]
            };
            e.house_id = i.id;
        }
        var s = this;
        s.setData({
            share: e.share ? e.share : 0,
            tel_phone: a.globalData["tel-phone"]
        });
        var r = a.getSecret(), o = a.globalData.userInfo || {};
        o && o.mobile && s.setData({
            isDis: !0,
            resPhone: o.mobile,
            loginYK: !1,
            isYK: !0
        }), wx.request({
            url: a.globalData.haozuBase + "/api/miniapps/house/",
            data: {
                house_id: e.house_id,
                mobile: o.mobile || "",
                user_guid: o.user_guid || "",
                currtime: r.currtime,
                sign: r.sign,
                uuid: wx.getStorageSync("first_code")
            },
            success: function(e) {
                var t = e.data;
                if (200 === t.code) {
                    var i = t.data.imageList, r = t.data.houseInfo;
                    t.data.employee_list, t.data.employee_list[0];
                    s.setData({
                        title: t.data.title,
                        house: r,
                        building: t.data.buildingInfo,
                        imgUrls: i,
                        houseNum: t.data.buildingHouseNumber,
                        total: i ? i.length : 0,
                        consultant: t.data.employee_list,
                        consultantA: t.data.employee_list[0],
                        tjlist: t.data.like_house
                    });
                    var o = t.data.employeeInfo;
                    o && Object.keys(o).length > 0 && s.setData({
                        cnName: o.cnName,
                        img: o.pic,
                        enName: o.enName,
                        title: o.title,
                        level: o
                    });
                    var u = t.data.buildingInfo.lat, l = t.data.buildingInfo.lng;
                    n.getPoint({
                        lat: u,
                        lng: l
                    }).then(function(e) {
                        s.setData({
                            mapUrl: "http://apis.map.qq.com/ws/staticmap/v2/?center=" + e.lat + "," + e.lng + "&zoom=15&size=750*400&maptype=roadmap&markers=size:large|color:0xFFCCFF|label:H|" + e.lat + "," + e.lng + "&key=" + a.globalData.tencentMapKey
                        });
                    }), a.orderDisabled(s, s.data.house.id, "house_id");
                    var d = {
                        id: "",
                        status: "",
                        circle_name: "",
                        district_name: "",
                        thumb_image: ""
                    };
                    for (var c in d) d[c] = r[c];
                    d.building_name = r.building_name, d.gongwei_number_min = r.gongwei_number_min, 
                    d.gongwei_number_max = r.gongwei_number_max, d.rent_price = r.avg_price, d.price_unit = r.avg_price_unit, 
                    d.total_price = r.price, d.total_price_unit = r.price_unit, d.zhuangxiu = r.briefIntroduction.zhuangxiu.val, 
                    d.area = r.area, d.type = 2;
                    var h = {
                        t: 2,
                        v: r.id,
                        c: r.city_id,
                        d: r.district_id,
                        ci: r.circle_id,
                        s: r.street_id,
                        vt: new Date().getTime()
                    };
                    a.saveStorage(h, d);
                }
                1 == e.data.data.isCollect && s.setData({
                    isSC: !0
                });
            }
        });
    },
    onReady: function(e) {
        var t = this, a = wx.createSelectorQuery();
        a.select(".head_swiper").boundingClientRect(), a.exec(function(e) {
            var a = e[0].width;
            t.setData({
                seeWidth: a - 30 * a / 750
            });
        });
    },
    touchStart: s.touchStart,
    touchEnd: function(e) {
        s.touchEnd.call(this, e), s.goFun.call(this, e);
    },
    turnScroll: s.turnScroll,
    turnEnd: function(e) {
        s.goFun.call(this, e);
    },
    showyekan: function(e) {
        this.setData({
            shade: !0,
            showYK: !0
        });
    },
    closeyuekan: function(e) {
        this.setData({
            shade: !1,
            showYK: !1
        });
    },
    inputChange: function(e) {
        this.setData({
            resPhone: e.detail.value
        });
    },
    submitYK: function(e) {
        var t = this, i = /^(13[0-9]|14[5|7]|15[0-9]|17[0|1|3|5|6|7|8]|18[0-9])\d{8}$/, n = t.data.resPhone;
        return !t.data.isYK && (i.test(n) ? (t.setData({
            hasError: !1
        }), void a.orderlogin({
            mobile: n,
            name: "小程序房源页预约",
            login: a.globalData.userInfo ? 0 : 1,
            house_id: t.data.house.id,
            building_name: t.data.house.building_name,
            from_page: 3
        }).then(function(e) {
            200 == e.code && (t.setData({
                showYK: !1,
                subsucc: !0,
                isYK: !0
            }), setTimeout(function() {
                t.setData({
                    shade: !1,
                    subsucc: !1
                });
            }, 3e3));
        })) : (t.setData({
            hasError: !0
        }), !1));
    },
    shouchang: function(e) {
        var t = this, i = a.globalData.userInfo || {};
        if (a.globalData.userInfo) {
            var n = a.getSecret();
            t.data.isSC ? wx.request({
                url: a.globalData.uchaozuBase + "/api/miniapps/collect/del/",
                data: {
                    uid: i.user_id || "",
                    type: "2",
                    opt_id: t.data.house.id,
                    currtime: n.currtime,
                    sign: n.sign
                },
                success: function(e) {
                    e.data;
                    if (500 === e.statusCode) return !1;
                    t.setData({
                        isSC: !1
                    });
                }
            }) : wx.request({
                url: a.globalData.uchaozuBase + "/api/miniapps/collect/add/",
                data: {
                    uid: i.user_id || "",
                    type: "2",
                    opt_id: t.data.house.id,
                    currtime: n.currtime,
                    sign: n.sign
                },
                success: function(e) {
                    e.data;
                    if (500 === e.statusCode) return !1;
                    t.setData({
                        isSC: !0
                    });
                }
            });
        } else wx.setStorage({
            key: "HdataInfo",
            data: {
                uid: i.user_id || "",
                type: "2",
                opt_id: t.data.house.id
            }
        }), wx.navigateTo({
            url: "/pages/getinfo/index"
        });
    },
    zixun: function(e) {
        wx.makePhoneCall({
            phoneNumber: e.currentTarget.dataset.phone
        });
    },
    zixunA: function() {
        wx.makePhoneCall({
            phoneNumber: this.data.consultantA.telephone
        });
    },
    showAll: function() {
        this.setData({
            isUp: !1
        });
    },
    xixika: function(e) {
        var t = [];
        t.push(e.currentTarget.dataset.id), wx.previewImage({
            current: e.currentTarget.dataset.id,
            urls: t
        });
    },
    zhizhao: function(e) {
        var t = [];
        t.push(e.currentTarget.dataset.id), wx.previewImage({
            current: e.currentTarget.dataset.id,
            urls: t
        });
    }
});